package com.atguigu.srb.core.controller.admin;


import com.atguigu.common.result.R;
import com.atguigu.srb.core.pojo.entity.BorrowInfo;
import com.atguigu.srb.core.pojo.vo.BorrowInfoApprovalVo;
import com.atguigu.srb.core.service.BorrowInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 借款信息表 前端控制器
 * </p>
 *
 * @author TieZhu
 * @since 2021-06-10
 */
@Api(tags = "借款管理")
@RestController
@RequestMapping("/admin/core/borrowInfo")
@Slf4j
public class AdminBorrowInfoController {
    @Resource
    private BorrowInfoService borrowInfoService;

    @ApiOperation("借款信息列表")
    @GetMapping("/list")
    public R BorrowInfoList(){
        List<BorrowInfo> borrowInfoList=borrowInfoService.selectList();
        return R.ok().data("list",borrowInfoList);
    }
    @GetMapping("/show/{id}")
    public R show(@ApiParam(value = "借款id",required = true) @PathVariable Long id){
        System.out.println("id" +id);
        Map<String,Object> borrowInfoDetail=borrowInfoService.getBorrowInfoDetail(id);
        return R.ok().data("borrowInfoDetail",borrowInfoDetail);
    }
    @ApiOperation("审批借款信息")
    @PostMapping("/approval")
    public R approval(@RequestBody BorrowInfoApprovalVo borrowInfoApprovalVo){
        borrowInfoService.approval(borrowInfoApprovalVo);
        return R.ok().message("审批完成");
    }

}

